package com.example.androidshixi;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class MyFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my, container, false);

        // 获取布局中的 TextView
        TextView myArticlesTextView = view.findViewById(R.id.my_articles_text_view);
        TextView myOrdersTextView = view.findViewById(R.id.my_orders_text_view);
        TextView shoppingCartTextView = view.findViewById(R.id.shopping_cart_text_view);
        TextView settingsTextView = view.findViewById(R.id.settings_text_view);

        // 设置点击事件
        myArticlesTextView.setOnClickListener(v -> {
            // 直接跳转到 "我的文章" 页面
            Intent intent = new Intent(requireContext(), MyArticlesActivity.class);
            startActivity(intent);
        });

        myOrdersTextView.setOnClickListener(v -> {
            Intent intent = new Intent(requireContext(), MyOrdersActivity.class);
            startActivity(intent);
        });

        shoppingCartTextView.setOnClickListener(v -> {
            Intent intent = new Intent(requireContext(), CartActivity.class);
            startActivity(intent);
        });

        settingsTextView.setOnClickListener(v -> {
            Intent intent = new Intent(requireContext(), SettingsActivity.class);
            startActivity(intent);
        });

        return view;
    }
}